package nbcp.service




//
//fun Exception.log2Db(module: String = "") {
//    try {
//        var ent = SysLog();
//        ent.createBy = SystemContext.userName;// HttpContext.nullableRequest?.session?.getAttribute("UserName")?.toString() ?: ""
//        ent.type = "Exception";
//        ent.msg = this.message ?: "";
//        ent.remark = this.stackTrace.map { it.toString() }.joinToString("\n");
//        ent.module = module;
//
//        mor.system.sysLog.insert(ent)
//    } catch (e: Exception) {
//        e.printStackTrace();
//    }
//}

fun Exception.toLogger(logger: org.slf4j.Logger, module: String = "") {
    try {
        logger.error("""[${module}] ${this.message}
${this.stackTrace.map { it.toString() }.joinToString("\n")}
    """.trimMargin())
    } catch (e: Exception) {
        e.printStackTrace();
    }
}